package wechat.app.test

import java.util.Date
import org.junit.Ignore
import org.junit.Test
import wechat.app.WXServiceAppFactoryDemo
//import wechat.app.domain.ScheduledTaskNotifyWeiXin
import wechat.base.snd.QRCode
import wechat.base.snd.QRCodeManager
import wechat.base.snd.WCTemplateContent

import static wechat.app.test.ServiceAppDemoTest.*
class ServiceAppDemoTest {
//	static Logger logger = Logger::getLogger("ServiceAppTest")
	
	static String TEMPLATE_DISPATH_MSG_ID = "v_CkyFvYjwXJq525Au4Lv71rslPW5pwcye3vPtBNlTU";
	
	//模板ID: v_CkyFvYjwXJq525Au4Lv71rslPW5pwcye3vPtBNlTU
	//{{first.DATA}}
	//任务名称：{{keyword1.DATA}}
	//相关人员：{{keyword2.DATA}}
	//{{remark.DATA}}
	//你好，微OA有新任务
	//任务名称：报销单等待审批
	//相关人员：「微语科技」晋明会
	//请尽快进行处理
	@Test
	@Ignore
	def void serviceAppWorkflow(){
		println('test=========>serviceAppWorkflow')
		WXServiceAppFactoryDemo::serviceApp=>[
			createTemplateNews()=>[
				withTempId(TEMPLATE_DISPATH_MSG_ID)
				withData(new WCTemplateContent()=>[
					withFirstItem("你好，微OA有新任务")
					withKeyword1Item("报销单等待审批")
					withKeyword2Item('「微语科技」晋明会')
					withRemarkItem('请尽快进行处理')
				])
				withUrl("www.baidu.com")
				send2Users(newArrayList('o9w_ht7bop9O2Ftn80x3UC2GynEY'))
			]
		]
	}
	
	@Test
	@Ignore	
	def void createSqrCode(){
		println('test=========>createSqrCode')
		new QRCodeManager(WXServiceAppFactoryDemo::serviceApp)=>[
			genPermTicket(new QRCode('11111')).getTicket("2222")
		]	
	}
	
	@Test
	@Ignore	
	def void getOpenId(){
		val code ="1"
		WXServiceAppFactoryDemo::serviceApp=>[
			println(getOpenId(code))
		]
	}
	
	@Test
	@Ignore
	def void sndTemplateMsgTestNoAuth(){
		println('test=========>sndTemplateMsgTestNoAuth')		
//		ScheduledTaskNotifyWeiXin::sendTemplateMsg_ServApp_NoAuth_ext('o9w_ht7bop9O2Ftn80x3UC2GynEY','609',new Date(), 'zhangsan','junit test')
	}
	
}
